<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.3.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"example.com","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.json"};
  </script>

  <meta name="description" content="搬砖 嵌入式">
<meta property="og:type" content="website">
<meta property="og:title" content="学无止境">
<meta property="og:url" content="http://example.com/page/5/index.html">
<meta property="og:site_name" content="学无止境">
<meta property="og:description" content="搬砖 嵌入式">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="xudonglei">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://example.com/page/5/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : true,
    isPost : false,
    lang   : 'zh-CN'
  };
</script>

  <title>学无止境</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">学无止境</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">Do not bb, show me the example</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content index posts-expand">
            
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/12/10/%E9%AB%98%E9%80%9F%E7%94%B5%E8%B7%AF%E9%80%BB%E8%BE%91%E7%94%B5%E5%B9%B3%E8%BD%AC%E6%8D%A2%E8%AE%BE%E8%AE%A1/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/12/10/%E9%AB%98%E9%80%9F%E7%94%B5%E8%B7%AF%E9%80%BB%E8%BE%91%E7%94%B5%E5%B9%B3%E8%BD%AC%E6%8D%A2%E8%AE%BE%E8%AE%A1/" class="post-title-link" itemprop="url">高速电路逻辑电平转换设计</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-12-10 15:21:19" itemprop="dateCreated datePublished" datetime="2023-12-10T15:21:19+08:00">2023-12-10</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E7%A1%AC%E4%BB%B6/" itemprop="url" rel="index"><span itemprop="name">硬件</span></a>
                </span>
            </span>

          
            <span id="/2023/12/10/%E9%AB%98%E9%80%9F%E7%94%B5%E8%B7%AF%E9%80%BB%E8%BE%91%E7%94%B5%E5%B9%B3%E8%BD%AC%E6%8D%A2%E8%AE%BE%E8%AE%A1/" class="post-meta-item leancloud_visitors" data-flag-title="高速电路逻辑电平转换设计" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/12/10/%E9%AB%98%E9%80%9F%E7%94%B5%E8%B7%AF%E9%80%BB%E8%BE%91%E7%94%B5%E5%B9%B3%E8%BD%AC%E6%8D%A2%E8%AE%BE%E8%AE%A1/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/12/10/%E9%AB%98%E9%80%9F%E7%94%B5%E8%B7%AF%E9%80%BB%E8%BE%91%E7%94%B5%E5%B9%B3%E8%BD%AC%E6%8D%A2%E8%AE%BE%E8%AE%A1/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        原文地址：<a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_21794157/article/details/122922877">https://blog.csdn.net/qq_21794157/article/details/122922877</a></p>
<h3 id="三极管做电平转换"><a href="#三极管做电平转换" class="headerlink" title="三极管做电平转换"></a>三极管做电平转换</h3><p>​        OC门输出的电路，在单板中做电平转换是较为常见的方法之一。当INPUT信号为1kHz频率时，2N3904处理起来不会有问题。下面进行仿真。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20231210150134.png" style="zoom:50%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20231210150311.png" style="zoom:60%;">

<p>​        如果将输入信号的频率提高到1MHz，仔细观察输入和输出信号的电平，可见此时输出信号的上升沿已经有些变缓。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20231210150604.png" style="zoom:60%;">

<p>​        现在将频率提高到10MHz，输出波形已经变成了三角波，输出信号已经产生了失真。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20231210150819.png" style="zoom:50%;">

<p>​        设想一下，如果这个电路用在一个视频传输信号上，数据传输的速率是27M，主平台输出的数据信号电平1.8V，用这个电路将1.8V转换到3.3V，接收端就会因为失真导致接收的数据出现错误。</p>
<h3 id="MOS管做电平转换"><a href="#MOS管做电平转换" class="headerlink" title="MOS管做电平转换"></a>MOS管做电平转换</h3><p>​        串口常用波特率为115200，按照起始位，数据位，校验位，传输一个bit所需的时间为8.6us。假设传输数据的序列为1010101010……，则一个周期是8.6us，最大所需的开关频率为116K左右。这样的频率，常见的MOS管开关频率可以做到。仿真的波形如下。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20231210153950.png" style="zoom:50%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20231210153936.png" style="zoom:50%;">

<p>​        证明了我们的理论分析，实际上由于串口发送的数据不可能是10101010…这样规则的序列，对MOS管开通和关断的速率要求可能更低。</p>
<p>​        根据以上基于分离器件做的电平转换，可以得出的结论是：</p>
<p>​        MOS管或者三级管作电平转换电路，需要看MOS管和三极管作为开关时，能否有足够的能力（带宽）处理高速的变化的电平信号。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/12/10/%E4%BD%8E%E9%80%9A%E6%BB%A4%E6%B3%A2multisim%E4%BB%BF%E7%9C%9F/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/12/10/%E4%BD%8E%E9%80%9A%E6%BB%A4%E6%B3%A2multisim%E4%BB%BF%E7%9C%9F/" class="post-title-link" itemprop="url">低通滤波multisim仿真</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-12-10 12:38:22" itemprop="dateCreated datePublished" datetime="2023-12-10T12:38:22+08:00">2023-12-10</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E7%A1%AC%E4%BB%B6/" itemprop="url" rel="index"><span itemprop="name">硬件</span></a>
                </span>
            </span>

          
            <span id="/2023/12/10/%E4%BD%8E%E9%80%9A%E6%BB%A4%E6%B3%A2multisim%E4%BB%BF%E7%9C%9F/" class="post-meta-item leancloud_visitors" data-flag-title="低通滤波multisim仿真" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/12/10/%E4%BD%8E%E9%80%9A%E6%BB%A4%E6%B3%A2multisim%E4%BB%BF%E7%9C%9F/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/12/10/%E4%BD%8E%E9%80%9A%E6%BB%A4%E6%B3%A2multisim%E4%BB%BF%E7%9C%9F/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>接地：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20231210130254.png" style="zoom:57%;">

<p>示波器：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20231210130924.png" style="zoom:50%;">

<p>修改示波器通道波形的颜色：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信图片_20231210133509.jpg" style="zoom:57%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20231210135344.png" style="zoom:50%;">

<p>​        在信号显示窗口下面，分别是时间轴，通道A,通道B的相关设置，调整时间轴的比例、通道A的比例、通道B的比例就可以放大或缩小时间与信号幅度；通道的比例下面是选择开关，如果要观察交流信号那么要选AC,要看直流信号选DC，如果暂时不想看该通道信号那么选0，B通道下面还有个反相开关，就是原来的值的相反数。</p>
<h3 id="频率特性测试仪"><a href="#频率特性测试仪" class="headerlink" title="频率特性测试仪"></a>频率特性测试仪</h3><p>​        频率特性测试仪可以用于测量和显示电路的幅频特性与相频特性，类似于扫频仪，如图所示为频率特性测试仪图标。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20231210140457.png" style="zoom:50%;">

<p>​        选择菜单栏中的“仿真”→“仪器”→“波特测试仪”命令，或者单击“仪器”工具栏中的“函数发生器”按钮，放置图标，双击频率特性测试仪图标，放大的频率特性测试仪的面板图如图所示。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20231210140959.png" style="zoom:50%;">

<p>​        该对话框中选项设置如下：</p>
<p>1.“模式”选项组<br> 在该选项组下设置输出方式选择区。</p>
<p>幅值:用于显示被测电路的幅频特性曲线。<br>相位:用于显示被测电路的相频特性曲线。<br>2.“水平”选项组<br>在该选项组下水平坐标(X轴)的频率显示格式设置区，水平轴总是显示频率的数值。</p>
<p>对数:水平坐标采用对数的显示格式。<br> 线性:水平坐标采用线性的显示格式。<br>F:水平坐标(频率)的最大值。<br>I:水平坐标(频率)的最小值。<br>3.“垂直”选项组<br>在该选项组下设置垂直坐标。</p>
<p>对数:垂直坐标采用对数的显示格式。<br>线性:垂直坐标采用线性的显示格式。<br>F:垂直坐标(频率)的最大值。<br> I:垂直坐标(频率)的最小值。<br>4.“控件”选项组<br>在该选项组下是输出控制区。</p>
<p>反向:将示波器显示屏的背景色由黑色改为白色。<br>保存:保存显示的频率特性曲线及其相关的参数设置。<br>设置:设置扫描的分辨率。<br><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20231210142338.png" style="zoom:50%;"></p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20231210142314.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20231210143216.png" style="zoom:67%;">
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/12/09/ESP32%20Arduino%E9%80%9A%E8%BF%87MQTT%E4%B8%8A%E4%BC%A0%E6%95%B0%E6%8D%AE%E8%87%B3OneNet/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/12/09/ESP32%20Arduino%E9%80%9A%E8%BF%87MQTT%E4%B8%8A%E4%BC%A0%E6%95%B0%E6%8D%AE%E8%87%B3OneNet/" class="post-title-link" itemprop="url">ESP32 Arduino通过MQTT上传数据至OneNet</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-12-09 18:34:52" itemprop="dateCreated datePublished" datetime="2023-12-09T18:34:52+08:00">2023-12-09</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2023/12/09/ESP32%20Arduino%E9%80%9A%E8%BF%87MQTT%E4%B8%8A%E4%BC%A0%E6%95%B0%E6%8D%AE%E8%87%B3OneNet/" class="post-meta-item leancloud_visitors" data-flag-title="ESP32 Arduino通过MQTT上传数据至OneNet" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/12/09/ESP32%20Arduino%E9%80%9A%E8%BF%87MQTT%E4%B8%8A%E4%BC%A0%E6%95%B0%E6%8D%AE%E8%87%B3OneNet/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/12/09/ESP32%20Arduino%E9%80%9A%E8%BF%87MQTT%E4%B8%8A%E4%BC%A0%E6%95%B0%E6%8D%AE%E8%87%B3OneNet/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​         原文链接：<a target="_blank" rel="noopener" href="https://blog.csdn.net/u014421313/article/details/125466427?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_baidulandingword~default-0-125466427-blog-130660447.235%5Ev39%5Epc_relevant_anti_vip&amp;spm=1001.2101.3001.4242.1&amp;utm_relevant_index=3">https://blog.csdn.net/u014421313/article/details/125466427?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_baidulandingword~default-0-125466427-blog-130660447.235^v39^pc_relevant_anti_vip&amp;spm=1001.2101.3001.4242.1&amp;utm_relevant_index=3</a></p>
<h3 id="OneNet平台配置"><a href="#OneNet平台配置" class="headerlink" title="OneNet平台配置"></a><strong>OneNet平台配置</strong></h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312091834134.png" style="zoom:50%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312091835921.png" style="zoom:67%;">

<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312091925105.png"></p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312092022948.png" style="zoom:67%;">

<p>​        添加好产品之后，就可以添加设备了。因为产品下面可以包含多个设备，并且这样的设备就是对应的硬件，所以一定要添加设备方可使用：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312092034081.png" style="zoom:67%;">

<p>​        添加设备里面的有个鉴权信息，这个非常重要，后面在设备登录的时候，需要用到，显示应该是可以自己定义的数据，具体鉴权信息用户可以自己添加，使用数字与符号，尽量不要用一些特殊字符代替。</p>
<p>​        这样就注册好了，然后设备会显示离线，这时只要模块发送数据到 ONENET 平台进行激活就可以了。</p>
<h3 id="ESP32安装库"><a href="#ESP32安装库" class="headerlink" title="ESP32安装库"></a><strong>ESP32安装库</strong></h3><p>​        打开arduino选择“工具”里的管理库，在管理库里搜索：Pub SubClient,安装完成后即可使用该库。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312092042160.png" style="zoom:67%;">

<h3 id="代码示例"><a href="#代码示例" class="headerlink" title="代码示例"></a>代码示例</h3><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;Arduino.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;WiFi.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;PubSubClient.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;Ticker.h&quot;</span></span></span><br><span class="line"> </span><br><span class="line"><span class="keyword">const</span> <span class="keyword">char</span> *ssid = <span class="string">&quot;360WiFi-99B5DF&quot;</span>;         <span class="comment">//wifi名</span></span><br><span class="line"><span class="keyword">const</span> <span class="keyword">char</span> *password = <span class="string">&quot;xxxxxxxxx&quot;</span>;          <span class="comment">//wifi密码</span></span><br><span class="line"><span class="keyword">const</span> <span class="keyword">char</span> *mqtt_server = <span class="string">&quot;183.230.40.39&quot;</span>;   <span class="comment">//onenet 的 IP地址</span></span><br><span class="line"> </span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> mqtt_devid <span class="meta-string">&quot;1172115522&quot;</span>    <span class="comment">//设备ID</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> mqtt_pubid <span class="meta-string">&quot;622583&quot;</span>        <span class="comment">//产品ID</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> mqtt_password <span class="meta-string">&quot;xxxxxxxxxx&quot;</span>  <span class="comment">//鉴权信息</span></span></span><br><span class="line"> </span><br><span class="line">WiFiClient espClient;           <span class="comment">//创建一个WIFI连接客户端</span></span><br><span class="line"><span class="function">PubSubClient <span class="title">client</span><span class="params">(espClient)</span></span>; <span class="comment">// 创建一个PubSub客户端, 传入创建的WIFI客户端</span></span><br><span class="line"> </span><br><span class="line"><span class="keyword">char</span> msg_buf[<span class="number">200</span>];                                    <span class="comment">//发送信息缓冲区</span></span><br><span class="line"><span class="keyword">char</span> dataTemplate[] = <span class="string">&quot;&#123;\&quot;temp\&quot;:%.2f,\&quot;hum\&quot;:%.2f&#125;&quot;</span>; <span class="comment">//信息模板</span></span><br><span class="line"><span class="keyword">char</span> msgJson[<span class="number">75</span>];                                     <span class="comment">//要发送的json格式的数据</span></span><br><span class="line"><span class="keyword">unsigned</span> <span class="keyword">short</span> json_len = <span class="number">0</span>;                          <span class="comment">//json长度</span></span><br><span class="line">Ticker tim1;                                          <span class="comment">//定时器,用来循环上传数据</span></span><br><span class="line"> </span><br><span class="line"><span class="comment">//连接WIFI相关函数</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">setupWifi</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">  delay(<span class="number">10</span>);</span><br><span class="line">  Serial.println(<span class="string">&quot;连接WIFI&quot;</span>);</span><br><span class="line">  WiFi.begin(ssid, password);</span><br><span class="line">  <span class="keyword">while</span> (!WiFi.isConnected())</span><br><span class="line">  &#123;</span><br><span class="line">    Serial.print(<span class="string">&quot;.&quot;</span>);</span><br><span class="line">    delay(<span class="number">500</span>);</span><br><span class="line">  &#125;</span><br><span class="line">  Serial.println(<span class="string">&quot;OK&quot;</span>);</span><br><span class="line">  Serial.println(<span class="string">&quot;Wifi连接成功&quot;</span>);</span><br><span class="line">&#125;</span><br><span class="line"> </span><br><span class="line"><span class="comment">//收到主题下发的回调, 注意这个回调要实现三个形参 1:topic 主题, 2: payload: 传递过来的信息 3: length: 长度</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">callback</span><span class="params">(<span class="keyword">char</span> *topic, byte *payload, <span class="keyword">unsigned</span> <span class="keyword">int</span> length)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">  Serial.println(<span class="string">&quot;message rev:&quot;</span>);</span><br><span class="line">  Serial.println(topic);</span><br><span class="line">  <span class="keyword">for</span> (<span class="keyword">size_t</span> i = <span class="number">0</span>; i &lt; length; i++)</span><br><span class="line">  &#123;</span><br><span class="line">    Serial.print((<span class="keyword">char</span>)payload[i]);</span><br><span class="line">  &#125;</span><br><span class="line">  Serial.println();</span><br><span class="line">&#125;</span><br><span class="line"> </span><br><span class="line"><span class="comment">//向主题发送模拟的温湿度数据</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">sendTempAndHumi</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">  <span class="keyword">if</span> (client.connected())</span><br><span class="line">  &#123;</span><br><span class="line">    <span class="built_in">snprintf</span>(msgJson, <span class="number">40</span>, dataTemplate, <span class="number">22.31</span>, <span class="number">25.92</span>); <span class="comment">//将模拟温湿度数据套入dataTemplate模板中, 生成的字符串传给msgJson</span></span><br><span class="line">    json_len = <span class="built_in">strlen</span>(msgJson);                        <span class="comment">//msgJson的长度</span></span><br><span class="line">    msg_buf[<span class="number">0</span>] = <span class="keyword">char</span>(<span class="number">0x03</span>);                           <span class="comment">//要发送的数据必须按照ONENET的要求发送, 根据要求,数据第一位是3</span></span><br><span class="line">    msg_buf[<span class="number">1</span>] = <span class="keyword">char</span>(json_len &gt;&gt; <span class="number">8</span>);                  <span class="comment">//数据第二位是要发送的数据长度的高八位</span></span><br><span class="line">    msg_buf[<span class="number">2</span>] = <span class="keyword">char</span>(json_len &amp; <span class="number">0xff</span>);                <span class="comment">//数据第三位是要发送数据的长度的低八位</span></span><br><span class="line">    <span class="built_in">memcpy</span>(msg_buf + <span class="number">3</span>, msgJson, <span class="built_in">strlen</span>(msgJson));    <span class="comment">//从msg_buf的第四位开始,放入要传的数据msgJson</span></span><br><span class="line">    msg_buf[<span class="number">3</span> + <span class="built_in">strlen</span>(msgJson)] = <span class="number">0</span>;                 <span class="comment">//添加一个0作为最后一位, 这样要发送的msg_buf准备好了</span></span><br><span class="line">    Serial.print(<span class="string">&quot;public message:&quot;</span>);</span><br><span class="line">    Serial.println(msgJson);</span><br><span class="line">    client.publish(<span class="string">&quot;$dp&quot;</span>, (<span class="keyword">uint8_t</span> *)msg_buf, <span class="number">3</span> + <span class="built_in">strlen</span>(msgJson)); <span class="comment">//发送数据到主题$dp</span></span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"> </span><br><span class="line"><span class="comment">//重连函数, 如果客户端断线,可以通过此函数重连</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">clientReconnect</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">  <span class="keyword">while</span> (!client.connected()) <span class="comment">//再重连客户端</span></span><br><span class="line">  &#123;</span><br><span class="line">    Serial.println(<span class="string">&quot;reconnect MQTT...&quot;</span>);</span><br><span class="line">    <span class="keyword">if</span> (client.connect(mqtt_devid, mqtt_pubid, mqtt_password))</span><br><span class="line">    &#123;</span><br><span class="line">      Serial.println(<span class="string">&quot;connected&quot;</span>);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">else</span></span><br><span class="line">    &#123;</span><br><span class="line">      Serial.println(<span class="string">&quot;failed&quot;</span>);</span><br><span class="line">      Serial.println(client.state());</span><br><span class="line">      Serial.println(<span class="string">&quot;try again in 5 sec&quot;</span>);</span><br><span class="line">      delay(<span class="number">5000</span>);</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"> </span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">setup</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">  Serial.begin(<span class="number">115200</span>);                                  <span class="comment">//初始化串口</span></span><br><span class="line">  delay(<span class="number">3000</span>);                                           <span class="comment">//这个延时是为了让我打开串口助手</span></span><br><span class="line">  setupWifi();                                           <span class="comment">//调用函数连接WIFI</span></span><br><span class="line">  client.setServer(mqtt_server, <span class="number">6002</span>);                   <span class="comment">//设置客户端连接的服务器,连接Onenet服务器, 使用6002端口</span></span><br><span class="line">  client.connect(mqtt_devid, mqtt_pubid, mqtt_password); <span class="comment">//客户端连接到指定的产品的指定设备.同时输入鉴权信息</span></span><br><span class="line">  client.setCallback(callback);                          <span class="comment">//设置好客户端收到信息是的回调</span></span><br><span class="line">  tim1.attach(<span class="number">20</span>, sendTempAndHumi);                      <span class="comment">//定时每20秒调用一次发送数据函数sendTempAndHumi</span></span><br><span class="line">&#125;</span><br><span class="line"> </span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">loop</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">  <span class="keyword">if</span> (!WiFi.isConnected()) <span class="comment">//先看WIFI是否还在连接</span></span><br><span class="line">  &#123;</span><br><span class="line">    setupWifi();</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="keyword">if</span> (!client.connected()) <span class="comment">//如果客户端没连接ONENET, 重新连接</span></span><br><span class="line">  &#123;</span><br><span class="line">    clientReconnect();</span><br><span class="line">  &#125;</span><br><span class="line">  client.loop(); <span class="comment">//客户端循环检测</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>​        ESP32连接到WiFi网络：确定连接WiFi的SSID和password，只需更改示例代码的ssid和password。”WiFiClient”是一个用于建立 TCP 连接的类，而 PubSubClient是一个 MQTT 客户端库，用于发布和接收 MQTT 消息。在这里，WiFiClient 用于建立与 MQTT 服务器的连接，而 PubSubClient用于发布和接收 MQTT 消息。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312092123261.png" style="zoom:67%;">

<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312092108201.png"></p>
<p>​        可以上传数据,也能接收到OneNet下发的命令:</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312092113798.png" style="zoom:67%;">

<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312092114408.png"></p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/12/07/%E7%94%B5%E5%8E%8B%E8%B7%9F%E9%9A%8F%E5%99%A8%E4%BD%9C%E7%94%A8/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/12/07/%E7%94%B5%E5%8E%8B%E8%B7%9F%E9%9A%8F%E5%99%A8%E4%BD%9C%E7%94%A8/" class="post-title-link" itemprop="url">电压跟随器作用</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-12-07 22:38:21" itemprop="dateCreated datePublished" datetime="2023-12-07T22:38:21+08:00">2023-12-07</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E7%A1%AC%E4%BB%B6/" itemprop="url" rel="index"><span itemprop="name">硬件</span></a>
                </span>
            </span>

          
            <span id="/2023/12/07/%E7%94%B5%E5%8E%8B%E8%B7%9F%E9%9A%8F%E5%99%A8%E4%BD%9C%E7%94%A8/" class="post-meta-item leancloud_visitors" data-flag-title="电压跟随器作用" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/12/07/%E7%94%B5%E5%8E%8B%E8%B7%9F%E9%9A%8F%E5%99%A8%E4%BD%9C%E7%94%A8/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/12/07/%E7%94%B5%E5%8E%8B%E8%B7%9F%E9%9A%8F%E5%99%A8%E4%BD%9C%E7%94%A8/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        原文链接：<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1c7411L7Z7/?spm_id_from=333.1007.top_right_bar_window_custom_collection.content.click&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8">https://www.bilibili.com/video/BV1c7411L7Z7/?spm_id_from=333.1007.top_right_bar_window_custom_collection.content.click&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8</a></p>
<p>​        <a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1mu41157LF/?spm_id_from=333.999.0.0&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8">https://www.bilibili.com/video/BV1mu41157LF/?spm_id_from=333.999.0.0&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8</a></p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20231207224030.png">（最基本的接法)</p>
<p>​        他有个特点，输入阻抗很高，输出阻抗很小。输出阻抗小，那它肯定带负载能力强，有更强的驱动下级电路的能力。(a)对前级和后级电路起到隔离的作用。（b）提高带负载能力。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20231207224422.png" style="zoom:57%;">

<p>比如前级是模拟电路，它的信号容易受干扰；后级是个数字电路，数字电路工作的时候经常会有比较高频的时钟，它会产生比较强的干扰，前级的模拟电路就特别怕这种干扰。</p>
<p>​        <img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20231207225019.png" style="zoom:57%;"></p>
<p>​        前后两级电路阻抗匹配。</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20231207225909.png"></p>
<p>​        最上面的那个电阻是起到保护的作用，当输出端受到静电的干扰，没有电阻的话就直接连到反向输入端，对反向输入端会产生一个比较大的冲击，有可能会损坏这个运放。另外在某些特殊情况下，反向输入端和通向输入端的电压差比较大，没有这个电阻也会使得运放损坏。</p>
<p>​        后面那个电阻一般和后级的输入阻抗有关，如果后级的输入阻抗不是很大，比如这个电阻就可以取到100欧。二极管起到防静电的作用。</p>
<p><strong>举个实例：</strong></p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20231207230654.png" style="zoom:80%;">

<p>U2是个稳压管，它上面那个点是2.5V的基准电压，R1是个限流电阻（因为U2是有功率的，所以要加R1），R1是10K，所以它后面的带载能力就没那么强了。</p>
<p>​        当把S1闭合，见下图的电压，影响很大：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20231207231320.png" style="zoom:80%;">

<p>带载的时候，不能对这个电压造成影响。</p>
<p>​        当把S2闭合，看下电压，没有影响：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20231207231624.png" style="zoom:67%;">

<p>​        比如再看下面这个电路：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20231207231957.png" style="zoom:50%;">

<p>​        单片机ADC想要采集A端的电压，因为运放输入阻抗无穷大，所以3号引脚那消耗的电流就很小，就不会对A端的电压带来大的影响。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/12/06/%E7%90%86%E8%A7%A3%E8%BF%90%E6%94%BE%E7%9A%84%E8%99%9A%E7%9F%AD%E5%92%8C%E8%99%9A%E6%96%AD/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/12/06/%E7%90%86%E8%A7%A3%E8%BF%90%E6%94%BE%E7%9A%84%E8%99%9A%E7%9F%AD%E5%92%8C%E8%99%9A%E6%96%AD/" class="post-title-link" itemprop="url">理解运放的虚短和虚断</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-12-06 22:25:17" itemprop="dateCreated datePublished" datetime="2023-12-06T22:25:17+08:00">2023-12-06</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E7%A1%AC%E4%BB%B6/" itemprop="url" rel="index"><span itemprop="name">硬件</span></a>
                </span>
            </span>

          
            <span id="/2023/12/06/%E7%90%86%E8%A7%A3%E8%BF%90%E6%94%BE%E7%9A%84%E8%99%9A%E7%9F%AD%E5%92%8C%E8%99%9A%E6%96%AD/" class="post-meta-item leancloud_visitors" data-flag-title="理解运放的虚短和虚断" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/12/06/%E7%90%86%E8%A7%A3%E8%BF%90%E6%94%BE%E7%9A%84%E8%99%9A%E7%9F%AD%E5%92%8C%E8%99%9A%E6%96%AD/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/12/06/%E7%90%86%E8%A7%A3%E8%BF%90%E6%94%BE%E7%9A%84%E8%99%9A%E7%9F%AD%E5%92%8C%E8%99%9A%E6%96%AD/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        原文链接：<a target="_blank" rel="noopener" href="https://www.youtube.com/watch?v=UMA-9ioQUkI&amp;list=PLhA_dF1ytURY8WpVXe7U_Xks3IFhF3-Ln&amp;index=1&amp;t=18s">https://www.youtube.com/watch?v=UMA-9ioQUkI&amp;list=PLhA_dF1ytURY8WpVXe7U_Xks3IFhF3-Ln&amp;index=1&amp;t=18s</a></p>
<h3 id="虚断"><a href="#虚断" class="headerlink" title="虚断"></a>虚断</h3><p>​        比如给运放施加一个电压，然后再串一个电流表，会发现电流表的读数接近0，说明没有电流流进这个运放。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312062229647.png" style="zoom:50%;">

<p>本质上我们只要知道<strong>理想运放的输入阻抗是无穷大</strong>的就行。</p>
<h3 id="虚短"><a href="#虚短" class="headerlink" title="虚短"></a>虚短</h3><p>​        给运放引入负反馈后，Un=Up。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312062232713.png" style="zoom:67%;">

<p>​        下面解释下上面这个结论：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312062236742.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312062237366.png" style="zoom:67%;">

<p>​        本质上是<strong>当给运放引入负反馈时，Un=Up</strong>。</p>
<h3 id="电路分析"><a href="#电路分析" class="headerlink" title="电路分析"></a>电路分析</h3><p>​        你会发现所有的运算电路都是负反馈电路：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312062241918.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312062244240.png" style="zoom:67%;">

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/12/02/%E5%8E%9F%E5%AD%90%E6%8E%A2%E7%B4%A2%E8%80%85%E5%BC%80%E5%8F%91%E6%9D%BF%E7%A7%BB%E6%A4%8Dlvgl/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/12/02/%E5%8E%9F%E5%AD%90%E6%8E%A2%E7%B4%A2%E8%80%85%E5%BC%80%E5%8F%91%E6%9D%BF%E7%A7%BB%E6%A4%8Dlvgl/" class="post-title-link" itemprop="url">原子探索者开发板移植lvgl</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-12-02 22:02:12" itemprop="dateCreated datePublished" datetime="2023-12-02T22:02:12+08:00">2023-12-02</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2023/12/02/%E5%8E%9F%E5%AD%90%E6%8E%A2%E7%B4%A2%E8%80%85%E5%BC%80%E5%8F%91%E6%9D%BF%E7%A7%BB%E6%A4%8Dlvgl/" class="post-meta-item leancloud_visitors" data-flag-title="原子探索者开发板移植lvgl" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/12/02/%E5%8E%9F%E5%AD%90%E6%8E%A2%E7%B4%A2%E8%80%85%E5%BC%80%E5%8F%91%E6%9D%BF%E7%A7%BB%E6%A4%8Dlvgl/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/12/02/%E5%8E%9F%E5%AD%90%E6%8E%A2%E7%B4%A2%E8%80%85%E5%BC%80%E5%8F%91%E6%9D%BF%E7%A7%BB%E6%A4%8Dlvgl/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        原文地址：<a target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/454677252">https://zhuanlan.zhihu.com/p/454677252</a></p>
<p>​        首先是获取LVGL源码，目前源码只在GitHub仓库中管理，可通过搜索LVGL官网转至git仓库或点击此仓库地址进行下载<a target="_blank" rel="noopener" href="https://github.com/lvgl">https://github.com/lvgl</a>.</p>
<p>​        下面将进行所需硬件配套驱动程序的准备。因为所要移植的是LVGL，所以显示屏驱动的必须的，此外还需移植显示屏的触摸驱动，以便进行触控调试。方便起见，这里直接在原子触摸屏驱动实验例程上修改。</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312022223031.png"></p>
<p>​        复制出后将文件更名为LVGL，并打开目录..\LVGL\USER将下图的两个文件也进行更名；</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312022225917.png" style="zoom:57%;">

<p>​        打开工程对工程名和目标文件输出目录名称做修改：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312030839263.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312030921077.png" style="zoom:50%;">

<p>​        编译工程，然后对工程进行调整，首先删除main.c中多余的内容，只保留下图所示的内容；</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312030926842.png" style="zoom:67%;">

<p>​        修改堆和栈大小，LVGL要求栈至少为2K,这里我们适当给大一点，STM32F4足够提供这个大小</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312030928222.png" style="zoom:60%;">

<p>​        使能C99编译器，否则工程无法编译通过.截止目前准备工作才算完成，简单编译一下原工程，确保无错误后咱们进行LVGL的移植工作。</p>
<p>​        首先在工程目录下添加两个文件夹LV以及GUI_APP,这两个文件夹分别用于存放LVGL的源码以及后期用户的应用代码：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312030935231.png" style="zoom:60%;">

<p>​        打开之前下载并解压好的LVGL源码,然后将下图红框中的三个文件复制到上一步创建的LV文件夹中，其中src为LVGL的各个组件源码，lv_conf_template.h为LVGL的配置文件，使用时用户可以通过此文件更改参数选项，lvgl.h为LVGL的各个头文件调用的文件。将这些文件拷贝到LV文件夹后，如下图所示:</p>
 <img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312030951770.png" style="zoom:67%;">

<p>将lv_conf_template.h重命名为lv_conf.h（这只是为了使用习惯的方便）。lv_conf.h默认是不使能的，所以需要打开lv_conf.h中的编译使能，将if 0 改为 if 1：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312030956605.png" style="zoom:50%;">

<p>​        打开Keil项目工程，然后参照LV\src目录，在工程目录下创建目录以及GUI_APP子条目，没有创建LV_GPU原因是我们所使用的开发板并未使用到GPU功能：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031001695.png" style="zoom:67%;">

<p>​        参照LV\src目录将对应的.c文件添加到上一步创建的条目中，这一步需要一定的耐心，这部分将会把所有的添加过程一 一列出：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031011245.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031012667.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031012291.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031013709.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031013707.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031014266.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031014019.png" style="zoom:67%;">

<p>​        上一步完成了.c文件的的导入，下面将对.h文件进行导入，添加完成后的目录下图所示。这也是个细致活：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031026788.png" style="zoom:67%;">

<p>添加完成后点击编译工程，没有错误。</p>
<p>​        这里还没完，不要着急，下面将移植显示驱动接口以及触摸驱动接口。打开gihub 下载解压后文件目录lvgl-master\examples\porting ，将会看到下图所示的的六个文件，其中lv_port_disp_template.c lv_port_disp_template.h文件为LVGL提供给用户实现的显示驱动接口；lv_port_indev_template.c lv_port_indev_template.h文件为LVGL提供给用户实现的触摸驱动接口；lv_port_fs_template.c lv_port_fs_template.h文件为LVGL提供给用户实现的文件系统接口。这里我们需要将lv_port_disp_template.c lv_port_disp_template.h lv_port_indev_template.c lv_port_indev_template.h四个文件复制到Keil工程的LV文件夹中并将其中的_template字段删除，如下图所示：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031035344.png" style="zoom:67%;">

<p>​        Keil 工程中增加LV_PORT的目录条目，如下所示，添加lv_port_indev.c lv_port_disp.c 文件：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031037250.png" style="zoom:67%;">

<p>​        修改lv_port_indev.h lv_port_disp.h的内容，因为二者默认是不启动编译的，修改内容改成#if 1。</p>
<p>​        修改lv_port_indev.c lv_port_disp.c文件，将lv_port_disp.c中的内容换为以下内容:</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * @file lv_port_disp_templ.c</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/*Copy this file as &quot;lv_port_disp.c&quot; and set this value to &quot;1&quot; to enable content*/</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">if</span> 1</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/*********************</span></span><br><span class="line"><span class="comment"> *      INCLUDES</span></span><br><span class="line"><span class="comment"> *********************/</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;lv_port_disp.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;../../lvgl.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;lcd.h&quot;</span></span></span><br><span class="line"></span><br><span class="line"><span class="comment">/*********************</span></span><br><span class="line"><span class="comment"> *      DEFINES</span></span><br><span class="line"><span class="comment"> *********************/</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">ifndef</span> MY_DISP_HOR_RES</span></span><br><span class="line">    <span class="meta">#<span class="meta-keyword">warning</span> Please <span class="meta-keyword">define</span> or replace the macro MY_DISP_HOR_RES with the actual screen width, default value 320 is used for now.</span></span><br><span class="line">    <span class="meta">#<span class="meta-keyword">define</span> MY_DISP_HOR_RES    320</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">ifndef</span> MY_DISP_VER_RES</span></span><br><span class="line">    <span class="meta">#<span class="meta-keyword">warning</span> Please <span class="meta-keyword">define</span> or replace the macro MY_DISP_HOR_RES with the actual screen height, default value 240 is used for now.</span></span><br><span class="line">    <span class="meta">#<span class="meta-keyword">define</span> MY_DISP_VER_RES    240</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br><span class="line"></span><br><span class="line"><span class="comment">/**********************</span></span><br><span class="line"><span class="comment"> *      TYPEDEFS</span></span><br><span class="line"><span class="comment"> **********************/</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/**********************</span></span><br><span class="line"><span class="comment"> *  STATIC PROTOTYPES</span></span><br><span class="line"><span class="comment"> **********************/</span></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">disp_init</span><span class="params">(<span class="keyword">void</span>)</span></span>;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">disp_flush</span><span class="params">(<span class="keyword">lv_disp_drv_t</span> * disp_drv, <span class="keyword">const</span> <span class="keyword">lv_area_t</span> * area, <span class="keyword">lv_color_t</span> * color_p)</span></span>;</span><br><span class="line"><span class="comment">//static void gpu_fill(lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width,</span></span><br><span class="line"><span class="comment">//        const lv_area_t * fill_area, lv_color_t color);</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/**********************</span></span><br><span class="line"><span class="comment"> *  STATIC VARIABLES</span></span><br><span class="line"><span class="comment"> **********************/</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/**********************</span></span><br><span class="line"><span class="comment"> *      MACROS</span></span><br><span class="line"><span class="comment"> **********************/</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/**********************</span></span><br><span class="line"><span class="comment"> *   GLOBAL FUNCTIONS</span></span><br><span class="line"><span class="comment"> **********************/</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">lv_port_disp_init</span><span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="comment">/*-------------------------</span></span><br><span class="line"><span class="comment">     * Initialize your display</span></span><br><span class="line"><span class="comment">     * -----------------------*/</span></span><br><span class="line">    disp_init();</span><br><span class="line"></span><br><span class="line">    <span class="comment">/*-----------------------------</span></span><br><span class="line"><span class="comment">     * Create a buffer for drawing</span></span><br><span class="line"><span class="comment">     *----------------------------*/</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * LVGL requires a buffer where it internally draws the widgets.</span></span><br><span class="line"><span class="comment">     * Later this buffer will passed to your display driver&#x27;s `flush_cb` to copy its content to your display.</span></span><br><span class="line"><span class="comment">     * The buffer has to be greater than 1 display row</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * There are 3 buffering configurations:</span></span><br><span class="line"><span class="comment">     * 1. Create ONE buffer:</span></span><br><span class="line"><span class="comment">     *      LVGL will draw the display&#x27;s content here and writes it to your display</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * 2. Create TWO buffer:</span></span><br><span class="line"><span class="comment">     *      LVGL will draw the display&#x27;s content to a buffer and writes it your display.</span></span><br><span class="line"><span class="comment">     *      You should use DMA to write the buffer&#x27;s content to the display.</span></span><br><span class="line"><span class="comment">     *      It will enable LVGL to draw the next part of the screen to the other buffer while</span></span><br><span class="line"><span class="comment">     *      the data is being sent form the first buffer. It makes rendering and flushing parallel.</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * 3. Double buffering</span></span><br><span class="line"><span class="comment">     *      Set 2 screens sized buffers and set disp_drv.full_refresh = 1.</span></span><br><span class="line"><span class="comment">     *      This way LVGL will always provide the whole rendered screen in `flush_cb`</span></span><br><span class="line"><span class="comment">     *      and you only need to change the frame buffer&#x27;s address.</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">/* Example for 1) */</span></span><br><span class="line">    <span class="keyword">static</span> <span class="keyword">lv_disp_draw_buf_t</span> draw_buf_dsc_1;</span><br><span class="line">    <span class="keyword">static</span> <span class="keyword">lv_color_t</span> buf_1[MY_DISP_HOR_RES * <span class="number">10</span>];                          <span class="comment">/*A buffer for 10 rows*/</span></span><br><span class="line">    lv_disp_draw_buf_init(&amp;draw_buf_dsc_1, buf_1, <span class="literal">NULL</span>, MY_DISP_HOR_RES * <span class="number">10</span>);   <span class="comment">/*Initialize the display buffer*/</span></span><br><span class="line"></span><br><span class="line"><span class="comment">//    /* Example for 2) */</span></span><br><span class="line"><span class="comment">//    static lv_disp_draw_buf_t draw_buf_dsc_2;</span></span><br><span class="line"><span class="comment">//    static lv_color_t buf_2_1[MY_DISP_HOR_RES * 10];                        /*A buffer for 10 rows*/</span></span><br><span class="line"><span class="comment">//    static lv_color_t buf_2_2[MY_DISP_HOR_RES * 10];                        /*An other buffer for 10 rows*/</span></span><br><span class="line"><span class="comment">//    lv_disp_draw_buf_init(&amp;draw_buf_dsc_2, buf_2_1, buf_2_2, MY_DISP_HOR_RES * 10);   /*Initialize the display buffer*/</span></span><br><span class="line"></span><br><span class="line"><span class="comment">//    /* Example for 3) also set disp_drv.full_refresh = 1 below*/</span></span><br><span class="line"><span class="comment">//    static lv_disp_draw_buf_t draw_buf_dsc_3;</span></span><br><span class="line"><span class="comment">//    static lv_color_t buf_3_1[MY_DISP_HOR_RES * MY_DISP_VER_RES];            /*A screen sized buffer*/</span></span><br><span class="line"><span class="comment">//    static lv_color_t buf_3_2[MY_DISP_HOR_RES * MY_DISP_VER_RES];            /*Another screen sized buffer*/</span></span><br><span class="line"><span class="comment">//    lv_disp_draw_buf_init(&amp;draw_buf_dsc_3, buf_3_1, buf_3_2,</span></span><br><span class="line"><span class="comment">//                          MY_DISP_VER_RES * LV_VER_RES_MAX);   /*Initialize the display buffer*/</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">/*-----------------------------------</span></span><br><span class="line"><span class="comment">     * Register the display in LVGL</span></span><br><span class="line"><span class="comment">     *----------------------------------*/</span></span><br><span class="line"></span><br><span class="line">    <span class="keyword">static</span> <span class="keyword">lv_disp_drv_t</span> disp_drv;                         <span class="comment">/*Descriptor of a display driver*/</span></span><br><span class="line">    lv_disp_drv_init(&amp;disp_drv);                    <span class="comment">/*Basic initialization*/</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">/*Set up the functions to access to your display*/</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">/*Set the resolution of the display*/</span></span><br><span class="line">    disp_drv.hor_res = lcddev.width;</span><br><span class="line">    disp_drv.ver_res = lcddev.height;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/*Used to copy the buffer&#x27;s content to the display*/</span></span><br><span class="line">    disp_drv.flush_cb = disp_flush;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/*Set a display buffer*/</span></span><br><span class="line">    disp_drv.draw_buf = &amp;draw_buf_dsc_1;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/*Required for Example 3)*/</span></span><br><span class="line">    <span class="comment">//disp_drv.full_refresh = 1;</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">/* Fill a memory array with a color if you have GPU.</span></span><br><span class="line"><span class="comment">     * Note that, in lv_conf.h you can enable GPUs that has built-in support in LVGL.</span></span><br><span class="line"><span class="comment">     * But if you have a different GPU you can use with this callback.*/</span></span><br><span class="line">    <span class="comment">//disp_drv.gpu_fill_cb = gpu_fill;</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">/*Finally register the driver*/</span></span><br><span class="line">    lv_disp_drv_register(&amp;disp_drv);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**********************</span></span><br><span class="line"><span class="comment"> *   STATIC FUNCTIONS</span></span><br><span class="line"><span class="comment"> **********************/</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/*Initialize your display and the required peripherals.*/</span></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">disp_init</span><span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="comment">/*You code here*/</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">volatile</span> <span class="keyword">bool</span> disp_flush_enabled = <span class="literal">true</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">/* Enable updating the screen (the flushing process) when disp_flush() is called by LVGL</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">disp_enable_update</span><span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    disp_flush_enabled = <span class="literal">true</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/* Disable updating the screen (the flushing process) when disp_flush() is called by LVGL</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">disp_disable_update</span><span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    disp_flush_enabled = <span class="literal">false</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/*Flush the content of the internal buffer the specific area on the display</span></span><br><span class="line"><span class="comment"> *You can use DMA or any hardware acceleration to do this operation in the background but</span></span><br><span class="line"><span class="comment"> *&#x27;lv_disp_flush_ready()&#x27; has to be called when finished.*/</span></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">disp_flush</span><span class="params">(<span class="keyword">lv_disp_drv_t</span> * disp_drv, <span class="keyword">const</span> <span class="keyword">lv_area_t</span> * area, <span class="keyword">lv_color_t</span> * color_p)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line"><span class="comment">//    if(disp_flush_enabled) &#123;</span></span><br><span class="line"><span class="comment">//        /*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/</span></span><br><span class="line"></span><br><span class="line"><span class="comment">//        int32_t x;</span></span><br><span class="line"><span class="comment">//        int32_t y;</span></span><br><span class="line"><span class="comment">//        for(y = area-&gt;y1; y &lt;= area-&gt;y2; y++) &#123;</span></span><br><span class="line"><span class="comment">//            for(x = area-&gt;x1; x &lt;= area-&gt;x2; x++) &#123;</span></span><br><span class="line"><span class="comment">//                /*Put a pixel to the display. For example:*/</span></span><br><span class="line"><span class="comment">//                /*put_px(x, y, *color_p)*/</span></span><br><span class="line"><span class="comment">//                color_p++;</span></span><br><span class="line"><span class="comment">//            &#125;</span></span><br><span class="line"><span class="comment">//        &#125;</span></span><br><span class="line"><span class="comment">//    &#125;</span></span><br><span class="line">		LCD_Color_Fill(area-&gt;x1,area-&gt;y1,area-&gt;x2,area-&gt;y2,(u16*)color_p);</span><br><span class="line"></span><br><span class="line">    <span class="comment">/*IMPORTANT!!!</span></span><br><span class="line"><span class="comment">     *Inform the graphics library that you are ready with the flushing*/</span></span><br><span class="line">    lv_disp_flush_ready(disp_drv);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/*OPTIONAL: GPU INTERFACE*/</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/*If your MCU has hardware accelerator (GPU) then you can use it to fill a memory with a color*/</span></span><br><span class="line"><span class="comment">//static void gpu_fill(lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width,</span></span><br><span class="line"><span class="comment">//                    const lv_area_t * fill_area, lv_color_t color)</span></span><br><span class="line"><span class="comment">//&#123;</span></span><br><span class="line"><span class="comment">//    /*It&#x27;s an example code which should be done by your GPU*/</span></span><br><span class="line"><span class="comment">//    int32_t x, y;</span></span><br><span class="line"><span class="comment">//    dest_buf += dest_width * fill_area-&gt;y1; /*Go to the first line*/</span></span><br><span class="line"><span class="comment">//</span></span><br><span class="line"><span class="comment">//    for(y = fill_area-&gt;y1; y &lt;= fill_area-&gt;y2; y++) &#123;</span></span><br><span class="line"><span class="comment">//        for(x = fill_area-&gt;x1; x &lt;= fill_area-&gt;x2; x++) &#123;</span></span><br><span class="line"><span class="comment">//            dest_buf[x] = color;</span></span><br><span class="line"><span class="comment">//        &#125;</span></span><br><span class="line"><span class="comment">//        dest_buf+=dest_width;    /*Go to the next line*/</span></span><br><span class="line"><span class="comment">//    &#125;</span></span><br><span class="line"><span class="comment">//&#125;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">else</span> <span class="comment">/*Enable this file at the top*/</span></span></span><br><span class="line"></span><br><span class="line"><span class="comment">/*This dummy typedef exists purely to silence -Wpedantic.*/</span></span><br><span class="line"><span class="keyword">typedef</span> <span class="keyword">int</span> keep_pedantic_happy;</span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br></pre></td></tr></table></figure>
<p>将lv_port_indev.c中的内容换为以下内容：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * @file lv_port_indev_templ.c</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"></span><br><span class="line"> <span class="comment">/*Copy this file as &quot;lv_port_indev.c&quot; and set this value to &quot;1&quot; to enable content*/</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">if</span> 1</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/*********************</span></span><br><span class="line"><span class="comment"> *      INCLUDES</span></span><br><span class="line"><span class="comment"> *********************/</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;lv_port_indev.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;../../lvgl.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;touch.h&quot;</span></span></span><br><span class="line"><span class="comment">/*********************</span></span><br><span class="line"><span class="comment"> *      DEFINES</span></span><br><span class="line"><span class="comment"> *********************/</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/**********************</span></span><br><span class="line"><span class="comment"> *      TYPEDEFS</span></span><br><span class="line"><span class="comment"> **********************/</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/**********************</span></span><br><span class="line"><span class="comment"> *  STATIC PROTOTYPES</span></span><br><span class="line"><span class="comment"> **********************/</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">touchpad_read</span><span class="params">(<span class="keyword">lv_indev_drv_t</span> * indev_drv, <span class="keyword">lv_indev_data_t</span> * data)</span></span>;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">lv_indev_t</span> * indev_touchpad;</span><br><span class="line"><span class="comment">/**********************</span></span><br><span class="line"><span class="comment"> *      MACROS</span></span><br><span class="line"><span class="comment"> **********************/</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/**********************</span></span><br><span class="line"><span class="comment"> *   GLOBAL FUNCTIONS</span></span><br><span class="line"><span class="comment"> **********************/</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">lv_port_indev_init</span><span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * Here you will find example implementation of input devices supported by LittelvGL:</span></span><br><span class="line"><span class="comment">     *  - Touchpad</span></span><br><span class="line"><span class="comment">     *  - Mouse (with cursor support)</span></span><br><span class="line"><span class="comment">     *  - Keypad (supports GUI usage only with key)</span></span><br><span class="line"><span class="comment">     *  - Encoder (supports GUI usage only with: left, right, push)</span></span><br><span class="line"><span class="comment">     *  - Button (external buttons to press points on the screen)</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     *  The `..._read()` function are only examples.</span></span><br><span class="line"><span class="comment">     *  You should shape them according to your hardware</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line"></span><br><span class="line">    <span class="keyword">static</span> <span class="keyword">lv_indev_drv_t</span> indev_drv;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/*------------------</span></span><br><span class="line"><span class="comment">     * Touchpad</span></span><br><span class="line"><span class="comment">     * -----------------*/</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">/*Initialize your touchpad if you have*/</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="comment">/*Register a touchpad input device*/</span></span><br><span class="line">    lv_indev_drv_init(&amp;indev_drv);</span><br><span class="line">    indev_drv.type = LV_INDEV_TYPE_POINTER;</span><br><span class="line">    indev_drv.read_cb = touchpad_read;</span><br><span class="line">    indev_touchpad = lv_indev_drv_register(&amp;indev_drv);</span><br><span class="line">    </span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">/*Will be called by the library to read the touchpad*/</span></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">touchpad_read</span><span class="params">(<span class="keyword">lv_indev_drv_t</span> * indev_drv, <span class="keyword">lv_indev_data_t</span> * data)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">static</span> <span class="keyword">lv_coord_t</span> last_x = <span class="number">0</span>;</span><br><span class="line">    <span class="keyword">static</span> <span class="keyword">lv_coord_t</span> last_y = <span class="number">0</span>;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span>(tp_dev.sta&amp;TP_PRES_DOWN)<span class="comment">//触摸按下了</span></span><br><span class="line">		&#123;</span><br><span class="line">			last_x = tp_dev.x[<span class="number">0</span>];</span><br><span class="line">			last_y = tp_dev.y[<span class="number">0</span>];</span><br><span class="line">			data-&gt;point.x = last_x;</span><br><span class="line">			data-&gt;point.y = last_y;</span><br><span class="line">			data-&gt;state = LV_INDEV_STATE_PR;</span><br><span class="line">		&#125;<span class="keyword">else</span>&#123;</span><br><span class="line">			data-&gt;point.x = last_x;</span><br><span class="line">			data-&gt;point.y = last_y;</span><br><span class="line">			data-&gt;state = LV_INDEV_STATE_REL;</span><br><span class="line">		&#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="meta">#<span class="meta-keyword">else</span> <span class="comment">/*Enable this file at the top*/</span></span></span><br><span class="line"></span><br><span class="line"><span class="comment">/*This dummy typedef exists purely to silence -Wpedantic.*/</span></span><br><span class="line"><span class="keyword">typedef</span> <span class="keyword">int</span> keep_pedantic_happy;</span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br></pre></td></tr></table></figure>
<p>main.c文件编写：<br>添加头文件<br>#include “lvgl.h”</p>
<p>#include “lv_port_disp.h”</p>
<p>#include “lv_port_indev.h”</p>
<p>初始化LVGL、显示接口以及触摸接口初始化一定要的LVGL初始化之后:</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031145120.png" style="zoom:67%;">

<p>​        编译工程无措无错误后为LVGL添加始终节拍，这里使用STM32的定时器3来提供时钟节拍，在工程中添加定时器配置的代码：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;timer.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;lvgl.h&quot;</span></span></span><br><span class="line"><span class="comment">//////////////////////////////////////////////////////////////////////////////////	 </span></span><br><span class="line"><span class="comment">//本程序只供学习使用，未经作者许可，不得用于其它任何用途</span></span><br><span class="line"><span class="comment">//ALIENTEK STM32F407开发板</span></span><br><span class="line"><span class="comment">//定时器 驱动代码	   </span></span><br><span class="line"><span class="comment">//正点原子@ALIENTEK</span></span><br><span class="line"><span class="comment">//技术论坛:www.openedv.com</span></span><br><span class="line"><span class="comment">//创建日期:2014/5/4</span></span><br><span class="line"><span class="comment">//版本：V1.0</span></span><br><span class="line"><span class="comment">//版权所有，盗版必究。</span></span><br><span class="line"><span class="comment">//Copyright(C) 广州市星翼电子科技有限公司 2014-2024</span></span><br><span class="line"><span class="comment">//All rights reserved									  </span></span><br><span class="line"><span class="comment">////////////////////////////////////////////////////////////////////////////////// 	 </span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">//通用定时器3中断初始化</span></span><br><span class="line"><span class="comment">//arr：自动重装值。</span></span><br><span class="line"><span class="comment">//psc：时钟预分频数</span></span><br><span class="line"><span class="comment">//定时器溢出时间计算方法:Tout=((arr+1)*(psc+1))/Ft us.</span></span><br><span class="line"><span class="comment">//Ft=定时器工作频率,单位:Mhz</span></span><br><span class="line"><span class="comment">//这里使用的是定时器3!</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">TIM3_Int_Init</span><span class="params">(u16 arr,u16 psc)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStructure;</span><br><span class="line">	NVIC_InitTypeDef NVIC_InitStructure;</span><br><span class="line">	</span><br><span class="line">	RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3,ENABLE);  <span class="comment">///使能TIM3时钟</span></span><br><span class="line">	</span><br><span class="line">  TIM_TimeBaseInitStructure.TIM_Period = arr; 	<span class="comment">//自动重装载值</span></span><br><span class="line">	TIM_TimeBaseInitStructure.TIM_Prescaler=psc;  <span class="comment">//定时器分频</span></span><br><span class="line">	TIM_TimeBaseInitStructure.TIM_CounterMode=TIM_CounterMode_Up; <span class="comment">//向上计数模式</span></span><br><span class="line">	TIM_TimeBaseInitStructure.TIM_ClockDivision=TIM_CKD_DIV1; </span><br><span class="line">	</span><br><span class="line">	TIM_TimeBaseInit(TIM3,&amp;TIM_TimeBaseInitStructure);<span class="comment">//初始化TIM3</span></span><br><span class="line">	</span><br><span class="line">	TIM_ITConfig(TIM3,TIM_IT_Update,ENABLE); <span class="comment">//允许定时器3更新中断</span></span><br><span class="line">	TIM_Cmd(TIM3,ENABLE); <span class="comment">//使能定时器3</span></span><br><span class="line">	</span><br><span class="line">	NVIC_InitStructure.NVIC_IRQChannel=TIM3_IRQn; <span class="comment">//定时器3中断</span></span><br><span class="line">	NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=<span class="number">0x01</span>; <span class="comment">//抢占优先级1</span></span><br><span class="line">	NVIC_InitStructure.NVIC_IRQChannelSubPriority=<span class="number">0x03</span>; <span class="comment">//子优先级3</span></span><br><span class="line">	NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;</span><br><span class="line">	NVIC_Init(&amp;NVIC_InitStructure);</span><br><span class="line">	</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//定时器3中断服务程序</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">TIM3_IRQHandler</span><span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123; 		    		  			    </span><br><span class="line">	<span class="keyword">if</span>(TIM3-&gt;SR&amp;TIM_IT_Update)<span class="comment">//溢出中断</span></span><br><span class="line">	&#123;</span><br><span class="line">		lv_tick_inc(<span class="number">1</span>);<span class="comment">//lvgl的1ms心跳</span></span><br><span class="line">	&#125;				   </span><br><span class="line">	TIM3-&gt;SR = (<span class="keyword">uint16_t</span>)~TIM_IT_Update;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>main.c中添加一下内容：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;sys.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;delay.h&quot;</span>  </span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;usart.h&quot;</span>   </span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;led.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;lcd.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;key.h&quot;</span>  </span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;touch.h&quot;</span> </span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;timer.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;lvgl.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;lv_port_disp.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;lv_port_indev.h&quot;</span></span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">event_handler</span><span class="params">(<span class="keyword">lv_event_t</span> * e)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">lv_event_code_t</span> code = lv_event_get_code(e);</span><br><span class="line">    <span class="keyword">lv_obj_t</span> * obj = lv_event_get_target(e);</span><br><span class="line">    <span class="keyword">if</span>(code == LV_EVENT_VALUE_CHANGED) &#123;</span><br><span class="line">        <span class="keyword">char</span> buf[<span class="number">32</span>];</span><br><span class="line">        lv_roller_get_selected_str(obj, buf, <span class="keyword">sizeof</span>(buf));</span><br><span class="line">        LV_LOG_USER(<span class="string">&quot;Selected month: %s\n&quot;</span>, buf);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * An infinite roller with the name of the months</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">lv_example_roller_1</span><span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">lv_obj_t</span> *roller1 = lv_roller_create(lv_scr_act());</span><br><span class="line">    lv_roller_set_options(roller1,</span><br><span class="line">                        <span class="string">&quot;January\n&quot;</span></span><br><span class="line">                        <span class="string">&quot;February\n&quot;</span></span><br><span class="line">                        <span class="string">&quot;March\n&quot;</span></span><br><span class="line">                        <span class="string">&quot;April\n&quot;</span></span><br><span class="line">                        <span class="string">&quot;May\n&quot;</span></span><br><span class="line">                        <span class="string">&quot;June\n&quot;</span></span><br><span class="line">                        <span class="string">&quot;July\n&quot;</span></span><br><span class="line">                        <span class="string">&quot;August\n&quot;</span></span><br><span class="line">                        <span class="string">&quot;September\n&quot;</span></span><br><span class="line">                        <span class="string">&quot;October\n&quot;</span></span><br><span class="line">                        <span class="string">&quot;November\n&quot;</span></span><br><span class="line">                        <span class="string">&quot;December&quot;</span>,</span><br><span class="line">                        LV_ROLLER_MODE_INFINITE);</span><br><span class="line"></span><br><span class="line">    lv_roller_set_visible_row_count(roller1, <span class="number">4</span>);</span><br><span class="line">    lv_obj_center(roller1);</span><br><span class="line">    lv_obj_add_event_cb(roller1, event_handler, LV_EVENT_ALL, <span class="literal">NULL</span>);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123; </span><br><span class="line"></span><br><span class="line">	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);<span class="comment">//设置系统中断优先级分组2</span></span><br><span class="line">	delay_init(<span class="number">168</span>);  <span class="comment">//初始化延时函数</span></span><br><span class="line">	uart_init(<span class="number">115200</span>);		<span class="comment">//初始化串口波特率为115200</span></span><br><span class="line">	</span><br><span class="line">	LED_Init();					<span class="comment">//初始化LED </span></span><br><span class="line"> 	LCD_Init();					<span class="comment">//LCD初始化 </span></span><br><span class="line">	KEY_Init(); 				<span class="comment">//按键初始化  </span></span><br><span class="line">    TIM3_Int_Init(<span class="number">999</span>,<span class="number">83</span>);</span><br><span class="line">	tp_dev.init();				<span class="comment">//触摸屏初始化</span></span><br><span class="line">    </span><br><span class="line">    lv_init();						<span class="comment">//lvgl系统初始化</span></span><br><span class="line">	lv_port_disp_init();	<span class="comment">//lvgl显示接口初始化,放在lv_init()的后面</span></span><br><span class="line">	lv_port_indev_init();	<span class="comment">//lvgl输入接口初始化,放在lv_init()的后面</span></span><br><span class="line">	</span><br><span class="line">    lv_example_roller_1();</span><br><span class="line">    <span class="keyword">while</span>(<span class="number">1</span>)</span><br><span class="line">    &#123;</span><br><span class="line">        tp_dev.scan(<span class="number">0</span>);</span><br><span class="line">		lv_task_handler();</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>编译并烧录到开发板中显示效果如图所示，至此LVGL移植成功：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031608793.jpg" style="zoom:60%;">

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/12/01/%E4%BD%BF%E7%94%A8wx%E4%B8%AD%E7%9A%84Panel/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/12/01/%E4%BD%BF%E7%94%A8wx%E4%B8%AD%E7%9A%84Panel/" class="post-title-link" itemprop="url">使用wx中的Panel</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-12-01 21:37:40" itemprop="dateCreated datePublished" datetime="2023-12-01T21:37:40+08:00">2023-12-01</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/python/" itemprop="url" rel="index"><span itemprop="name">python</span></a>
                </span>
            </span>

          
            <span id="/2023/12/01/%E4%BD%BF%E7%94%A8wx%E4%B8%AD%E7%9A%84Panel/" class="post-meta-item leancloud_visitors" data-flag-title="使用wx中的Panel" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/12/01/%E4%BD%BF%E7%94%A8wx%E4%B8%AD%E7%9A%84Panel/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/12/01/%E4%BD%BF%E7%94%A8wx%E4%B8%AD%E7%9A%84Panel/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​         原文链接：<a target="_blank" rel="noopener" href="https://blog.csdn.net/weixin_43212830/article/details/95168015">https://blog.csdn.net/weixin_43212830/article/details/95168015</a></p>
<p>​        看下面这个图，窗口背景一直是灰色的：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312012159748.png" style="zoom:50%;">

<p>​        这个灰色的背景，主要是因为我们没有使用容器，如果我们放一个容器进去会不会好一些呢。那么wxPython有没有容器呢？肯定是有的。其实我们上一次定义的Frame窗口就是一个容器，因为它本身就是一个窗口容器，可以容纳控件等等。而我们能不能在这个顶级窗口容器中再添加一些以Frame为父级的子容器呢？这时，我们就要用到Panel面板了。<br>​        <strong>我们为了能够更好地布局窗口内的控件，来应对窗口大小的变化，就需要用到面板。</strong>以后，如果有什么控件需要放到这个窗口中，就直接把控件放在这个面板中就行了。<br>​        我们先来看看代码：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> wx</span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">MyFrame</span>(<span class="params">wx.Frame</span>):</span>  <span class="comment">#该对象继承于wx.Frame框架</span></span><br><span class="line">	<span class="function"><span class="keyword">def</span> <span class="title">__init__</span>(<span class="params">self</span>):</span></span><br><span class="line">		<span class="built_in">super</span>().__init__(parent=<span class="literal">None</span>,title=<span class="string">&quot;窗口&quot;</span>,size=(<span class="number">400</span>,<span class="number">300</span>),pos=(<span class="number">100</span>,<span class="number">100</span>))</span><br><span class="line">		panel = wx.Panel(parent=self)<span class="comment">#将父级容器定义为窗口（就是这个当前窗口对象self）</span></span><br><span class="line">		statictext = wx.StaticText(parent=panel,label=<span class="string">&#x27;文字1&#x27;</span>,pos=(<span class="number">20</span>,<span class="number">20</span>))<span class="comment">#文字标签</span></span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">App</span>(<span class="params">wx.App</span>):</span>        <span class="comment">#该对象继承于wx.App框架</span></span><br><span class="line">	<span class="function"><span class="keyword">def</span> <span class="title">OnInit</span>(<span class="params">self</span>):</span>     <span class="comment">#直接实例化该对象并调用此函数，相当于显示，然后直接在main中进入主事件循环</span></span><br><span class="line">		frame = MyFrame()<span class="comment">#执行窗口定义</span></span><br><span class="line">		frame.Show()</span><br><span class="line">		<span class="keyword">return</span> <span class="literal">True</span></span><br><span class="line">	<span class="function"><span class="keyword">def</span> <span class="title">OnExit</span>(<span class="params">self</span>):</span>     <span class="comment">#可以在这里释放一些资源</span></span><br><span class="line">		print(<span class="string">&quot;应用程序退出&quot;</span>)</span><br><span class="line">		<span class="keyword">return</span> <span class="number">0</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> __name__ == <span class="string">&#x27;__main__&#x27;</span>:<span class="comment">#判断是否是主进程</span></span><br><span class="line">	app=App()</span><br><span class="line">	app.MainLoop()         <span class="comment">#在这里调用主事件循环</span></span><br></pre></td></tr></table></figure>
<p>​        就是说，我们如果定义了一个面板，想把该面板放在哪个容器或面板下，就将parent参数设为谁。比如我们这里就将窗口容器作为父容器。我们还可以在该面板中定义一个静态文本框，我们来看一下运行结果：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312012203398.png" style="zoom:50%;">
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/11/27/%E7%81%AF%E5%93%A5%E6%95%99%E7%A8%8B%E4%B9%8B%E9%97%AD%E7%8E%AF%E4%BD%8D%E7%BD%AE%E4%BB%A3%E7%A0%81%E5%89%8D%E7%BD%AE%E7%9F%A5%E8%AF%86/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/11/27/%E7%81%AF%E5%93%A5%E6%95%99%E7%A8%8B%E4%B9%8B%E9%97%AD%E7%8E%AF%E4%BD%8D%E7%BD%AE%E4%BB%A3%E7%A0%81%E5%89%8D%E7%BD%AE%E7%9F%A5%E8%AF%86/" class="post-title-link" itemprop="url">灯哥教程之闭环位置代码前置知识</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-11-27 21:41:05" itemprop="dateCreated datePublished" datetime="2023-11-27T21:41:05+08:00">2023-11-27</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E7%94%B5%E6%9C%BA/" itemprop="url" rel="index"><span itemprop="name">电机</span></a>
                </span>
            </span>

          
            <span id="/2023/11/27/%E7%81%AF%E5%93%A5%E6%95%99%E7%A8%8B%E4%B9%8B%E9%97%AD%E7%8E%AF%E4%BD%8D%E7%BD%AE%E4%BB%A3%E7%A0%81%E5%89%8D%E7%BD%AE%E7%9F%A5%E8%AF%86/" class="post-meta-item leancloud_visitors" data-flag-title="灯哥教程之闭环位置代码前置知识" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/11/27/%E7%81%AF%E5%93%A5%E6%95%99%E7%A8%8B%E4%B9%8B%E9%97%AD%E7%8E%AF%E4%BD%8D%E7%BD%AE%E4%BB%A3%E7%A0%81%E5%89%8D%E7%BD%AE%E7%9F%A5%E8%AF%86/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/11/27/%E7%81%AF%E5%93%A5%E6%95%99%E7%A8%8B%E4%B9%8B%E9%97%AD%E7%8E%AF%E4%BD%8D%E7%BD%AE%E4%BB%A3%E7%A0%81%E5%89%8D%E7%BD%AE%E7%9F%A5%E8%AF%86/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        原文链接：<a target="_blank" rel="noopener" href="http://www.dengfoc.com/#/dengfoc/%E7%81%AF%E5%93%A5%E6%89%8B%E6%8A%8A%E6%89%8B%E6%95%99%E4%BD%A0%E5%86%99FOC%E7%AE%97%E6%B3%95/5.1FOC%E9%97%AD%E7%8E%AF%E4%BD%8D%E7%BD%AE%E4%BB%A3%E7%A0%81%E5%8E%9F%E7%90%86%E6%95%99%E5%AD%A6">http://www.dengfoc.com/#/dengfoc/%E7%81%AF%E5%93%A5%E6%89%8B%E6%8A%8A%E6%89%8B%E6%95%99%E4%BD%A0%E5%86%99FOC%E7%AE%97%E6%B3%95/5.1FOC%E9%97%AD%E7%8E%AF%E4%BD%8D%E7%BD%AE%E4%BB%A3%E7%A0%81%E5%8E%9F%E7%90%86%E6%95%99%E5%AD%A6</a></p>
<h3 id="闭环位置控制的本质"><a href="#闭环位置控制的本质" class="headerlink" title="闭环位置控制的本质"></a>闭环位置控制的本质</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202311272147332.png" style="zoom:50%;">

<p>​        在写代码之前，首先我们需要明白闭环位置控制的本质。显然，常见的需要闭环位置控制的情况就如上图所示。现在，先假设我们给电机设置期望角度为0度，此时，电机蓝色的箭头指着屏幕右方的方向，与alpha轴重合。</p>
<p>  这时，我们用手逆时针扭转电机，把电机扭转到蓝色箭头与alpha轴形成45度的偏差。这时候，电机就会变成图中右边那样，显然，此时如果需要回正到原本我们设定并且期望的0度，那么电机就要产生一个如图中红色箭头所示的相反的力矩才能够回到电机的初始位置，力矩在这里是和Uq是等效的，也就是说，我们需要产生一个合适的Uq电压值，使得电机能够顺时针回转回0位。那么<strong>所谓闭环位置控制的方法，实际上就可以归纳为怎么检测这个角度偏差，以及怎么产生合适的旋转力矩Uq的问题</strong>。</p>
<p>​        在这里，我们首先设定逆时针旋转方向为负方向，顺时针旋转方向为正方向，并且在此时，设定电机的偏差位置采用e来进行表示，因此，误差位置可以用这条公式进行计算：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202311272150972.png" style="zoom:80%;">

<p>​        我们接下来的问题，就是如何我们需要根据-45度求出一个力矩Uq，使得Uq能够让电机产生力矩，使得电机转子回位的问题。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202311272204340.png" style="zoom:57%;">

<p>​        接下来我们就开始来探寻怎样把这个45度转化为我们的电机力矩。        </p>
<p>​        显然，我们不能直接让Uq=偏差值=45，这时不合理的，首先，我们的供电电压只有12v，直接让Uq=偏差值=45会导致电压远远超过了供电电压值。实际上，我们可以通过供电电压来计算出我们Uq能设定的最大值，以12v供电为例，实际上我们能够设定的Uq最大值仅有12v/2=±6V。为什么是6v？为什么要除2？这时因为，在上一节课中，我们已经把我们的ua,ub,uc曲线移动到供电电压中央，如下图代码所示：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202311272206787.png" style="zoom:50%;">

<p>​        在加上了供电电压变量voltage_power_supply/2后，实际上ua,ub,uc曲线的0点就由6v开始，而这个移动是必须的，因为不这么移动，ua,ub,uc的正弦波特性会使得驱动出现负电压，如下图所示，这显然不可接受。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202311272208563.png" style="zoom:50%;">

<p>​        那么，移动后，显然ua,ub,uc的变化范围就只有±6了，这也影响到了uq,因此，uq的变化范围也会仅剩下±6，如下图所示：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202311272209801.png" style="zoom:50%;">

<p>​        由此，我们就通过供电电压，确定了Uq的最大值Uqmax，有了这个值作为参考，我们就可以很快计算出怎样才能让电机在45度偏差时需要回正所需要的力矩输出大小，也就是我们的Uq大小。</p>
<p>  假设我们希望电机在偏差达到45度的时候，电机就会输出最大的回正力矩，由于我们前面设定了逆时针旋转是正方向，也就是说，我们希望电机此时输出的Uq=-6V，和我们刚刚计算出来的Uqmax相等。那么，显然我们就可以通过这条式子，得到他们的换算关系，我们把这个计算出来的换算系数，称为Kp：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202311272211403.png" style="zoom:67%;">

<p>​        显然，在求出这个Kp后，我们就能够通过一个简单的乘法，列出偏差e和Uq的换算关系式：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202311272212753.png" style="zoom:50%;">

<p>​        对应我们的电机在e=-45度偏差的时候，会产生Uq产生接近-6v的值-5.985v。</p>
<p>  而这个Kp，正是我们常说的PID控制器中的p环系数，我们刚刚的推导，正是PID中p环的纠偏原理！</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202311272219088.png" style="zoom:50%;">

<p>​        当然，实际上PID控制器，还有I环和D环两环没有介绍，我们今天仅仅介绍了P环在无刷电机位置闭环上的纠偏实现！而I环和D环怎么应用在电机上，未来再说。在这里先提一嘴，避免混淆。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202311272220915.png" style="zoom:50%;">

<p>​        我们把刚刚我们得到的关系式提取出来，就有了上图所示的式子，Kp我们已经知道是怎么算出来的了，而这个式子中的e,则是由我们的编码器测量得到。如图中我们定制开发的as5600编码器。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202311272221329.png" style="zoom:60%;">

<p>​        进一步总结起来，我们的的闭环位置控制框图就如PPT所示。相比于开环的过程，其实它就只是增加了我们刚刚前面讲的P控制器部分。可以看到，开头这里我们先通过编码器的读数算出了e，然后将这个e输入到P控制器中。当我们按照前面所讲述的内容计算并设定好我们所需要的P参数后，P控制器就会计算出一个可以用于纠正偏差的Uq，并将其输入给FOC算法，计算出所需要的Ualpha和Ubeta，以及最后输出ua,ub,uc给无刷电机，驱动电机转动，这些都是上面课程的内容了。通过这一波操作，我们就能够完成电机位置闭环。</p>
<p>  需要额外注意的是，电机位置闭环控制中，帕克逆变换计算所需要用到的电角度，也是由编码器测出的，当让，编码器能测出的只是机械角度，还需按照之前课程的内容，给编码器乘上极对数才能够转化为帕克逆变换所需要的电角度。</p>
<h3 id="注意事项"><a href="#注意事项" class="headerlink" title="注意事项"></a>注意事项</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202311282112178.png" style="zoom:67%;">

<p>​        就是我们当前所讲述的位置闭环其实只是方式1，也就是位置-力闭环控制，有些人也称之为力位控制，当然，实际上我们今天的控制并没有完整的实现位置-力控制，我们仅仅只是对位置进行了闭环而尚未对力矩进行闭环。</p>
<p>  另外，实现位置闭环的方式也不仅仅只有方式1这一种，实际上，方式2也很常见，就是通过位置环偏差，先输出一个速度环期望，再输出一个力矩期望给力矩环，实现三环嵌套位置闭环控制。当然，基础的学习还是得从简单开始。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/11/21/FD2606S%E8%8A%AF%E7%89%87%EF%BC%9AMOS%E7%AE%A1%E5%8D%8A%E6%A1%A5%E9%A9%B1%E5%8A%A8%E7%94%B5%E8%B7%AF%E6%96%B9%E6%A1%88/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/11/21/FD2606S%E8%8A%AF%E7%89%87%EF%BC%9AMOS%E7%AE%A1%E5%8D%8A%E6%A1%A5%E9%A9%B1%E5%8A%A8%E7%94%B5%E8%B7%AF%E6%96%B9%E6%A1%88/" class="post-title-link" itemprop="url">FD2606S芯片：MOS管半桥驱动电路方案</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-11-21 19:31:24" itemprop="dateCreated datePublished" datetime="2023-11-21T19:31:24+08:00">2023-11-21</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E7%94%B5%E6%9C%BA/" itemprop="url" rel="index"><span itemprop="name">电机</span></a>
                </span>
            </span>

          
            <span id="/2023/11/21/FD2606S%E8%8A%AF%E7%89%87%EF%BC%9AMOS%E7%AE%A1%E5%8D%8A%E6%A1%A5%E9%A9%B1%E5%8A%A8%E7%94%B5%E8%B7%AF%E6%96%B9%E6%A1%88/" class="post-meta-item leancloud_visitors" data-flag-title="FD2606S芯片：MOS管半桥驱动电路方案" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/11/21/FD2606S%E8%8A%AF%E7%89%87%EF%BC%9AMOS%E7%AE%A1%E5%8D%8A%E6%A1%A5%E9%A9%B1%E5%8A%A8%E7%94%B5%E8%B7%AF%E6%96%B9%E6%A1%88/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/11/21/FD2606S%E8%8A%AF%E7%89%87%EF%BC%9AMOS%E7%AE%A1%E5%8D%8A%E6%A1%A5%E9%A9%B1%E5%8A%A8%E7%94%B5%E8%B7%AF%E6%96%B9%E6%A1%88/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​         原文链接：<a target="_blank" rel="noopener" href="https://baijiahao.baidu.com/s?id=1733156461294144888">https://baijiahao.baidu.com/s?id=1733156461294144888</a></p>
<p>​        半桥驱动电路是什么电路？它是由两个MOS管构成的电路，其中一个MOS管的源极与另外一个MOS管的漏极连接在一起。既然它是由两个MOS管构成，很显然，设计半桥驱动电路，肯定需要设计MOS管的栅极驱动电路。</p>
<p>​        我们知道，MOS管它分为N沟道与P沟道。那半桥驱动的两个MOS管，是用哪种类型的MOS管呢？</p>
<p>其实，两个N沟道的MOS管可以，一个N沟道的MOS管与一个P沟道的MOS管也可以。这两种选择，有什么区别呢？</p>
<p>​        就电路方案而言，区别在于他们的栅极驱动电路是不同的。这里以两个N沟道MOS管为例，做个半桥驱动电路的详细说明</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/a50f4bfbfbedab6485a8273042bcf5c97b311ef8.webp" style="zoom:80%;">

<p>​        在这个FD2606S为核心的MOS管半桥驱动电路中，Q1与Q2是两个MOS管，型号为NCE65T1K2K，属于N沟道类型。</p>
<p>​        它们的栅极分别是通过一个电阻连接到芯片的HO引脚和LO引脚。当HIN引脚输入高电平，HO引脚输出电平，可以驱动Q1的MOS管导通；当LIN引脚为高电平，LO引脚输出的电平，可以驱动Q2的MOS管导通。</p>
<p>​        Q2的MOS管导通，工程师或许很容易理解，因为源极是接GND，所以只需要栅极的电压，大于它的开启电压，MOS管就会导通，此时VOUT就会输出0V。</p>
<p>​        关键是Q1的MOS管，它是如何导通的呢？根据电容的特性，它的两端电压是不能产生突变的，也就是在某一时刻，电容两端的电压是维持不变的。</p>
<p>​        假如Q2的MOS管导通，此时电容C2两端的电压是电源VCC（忽略D1二极管的压降差），它会通过芯片的VB引脚，输入反馈到芯片的内部电路，处理后，经过HO引脚驱动Q1的MOS管栅极。</p>
<p>​        就这样，VB引脚的电压，始终是要比VS引脚的电压高出VCC的电压值，也就是相当于Q1的MOS管栅极电压，始终要高于源极电压的，高出的部分就是VCC电压值。</p>
<p>​        所以作为高端输出部分Q1的MOS管，它导通就会输出200V的高压。这样就构成了一个完整的半桥驱动电路了。</p>
<p>​        当Q2的MOS管导通，VOUT就会输出低端的0V电压；当Q1的MOS管导通，VOUT就会输出高端的200V电压。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/11/21/python%E5%81%9A%E6%9B%B2%E7%BA%BF%E6%8B%9F%E5%90%88/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/11/21/python%E5%81%9A%E6%9B%B2%E7%BA%BF%E6%8B%9F%E5%90%88/" class="post-title-link" itemprop="url">python做曲线拟合</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-11-21 10:06:49" itemprop="dateCreated datePublished" datetime="2023-11-21T10:06:49+08:00">2023-11-21</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/python/" itemprop="url" rel="index"><span itemprop="name">python</span></a>
                </span>
            </span>

          
            <span id="/2023/11/21/python%E5%81%9A%E6%9B%B2%E7%BA%BF%E6%8B%9F%E5%90%88/" class="post-meta-item leancloud_visitors" data-flag-title="python做曲线拟合" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/11/21/python%E5%81%9A%E6%9B%B2%E7%BA%BF%E6%8B%9F%E5%90%88/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/11/21/python%E5%81%9A%E6%9B%B2%E7%BA%BF%E6%8B%9F%E5%90%88/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"><span class="keyword">import</span> matplotlib.pyplot <span class="keyword">as</span> plt</span><br><span class="line"></span><br><span class="line">x = np.array(</span><br><span class="line">    [-<span class="number">60</span> * np.pi / <span class="number">180</span>, -<span class="number">37</span> * np.pi / <span class="number">180</span>, -<span class="number">34</span> * np.pi / <span class="number">180</span>, -<span class="number">19</span> * np.pi / <span class="number">180</span>, <span class="number">0</span>, <span class="number">20</span> * np.pi / <span class="number">180</span>, <span class="number">36</span> * np.pi / <span class="number">180</span>,</span><br><span class="line">     <span class="number">38</span> * np.pi / <span class="number">180</span>, <span class="number">59</span> * np.pi / <span class="number">180</span>])</span><br><span class="line">y = np.array(</span><br><span class="line">    [-<span class="number">60</span> * np.pi / <span class="number">180</span>, -<span class="number">45</span> * np.pi / <span class="number">180</span>, -<span class="number">30</span> * np.pi / <span class="number">180</span>, -<span class="number">15</span> * np.pi / <span class="number">180</span>, <span class="number">0</span>, <span class="number">15</span> * np.pi / <span class="number">180</span>, <span class="number">30</span> * np.pi / <span class="number">180</span>,</span><br><span class="line">     <span class="number">45</span> * np.pi / <span class="number">180</span>, <span class="number">60</span> * np.pi / <span class="number">180</span>])</span><br><span class="line"></span><br><span class="line">plt.scatter(x, y)</span><br><span class="line">plt.show()</span><br><span class="line"></span><br><span class="line">parameter = np.polyfit(x, y, <span class="number">3</span>)</span><br><span class="line">print(parameter)</span><br><span class="line">y2 = parameter[<span class="number">0</span>] * x ** <span class="number">3</span> + parameter[<span class="number">1</span>] * x ** <span class="number">2</span> + parameter[<span class="number">2</span>] * x + parameter[<span class="number">3</span>]</span><br><span class="line">plt.scatter(x, y)</span><br><span class="line">plt.plot(x, y2, color=<span class="string">&#x27;g&#x27;</span>)</span><br><span class="line">plt.show()</span><br></pre></td></tr></table></figure>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/Figure_112112.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/Figure_2232324.png" style="zoom:67%;">

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  


  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/page/4/"><i class="fa fa-angle-left" aria-label="上一页"></i></a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/4/">4</a><span class="page-number current">5</span><a class="page-number" href="/page/6/">6</a><span class="space">&hellip;</span><a class="page-number" href="/page/29/">29</a><a class="extend next" rel="next" href="/page/6/"><i class="fa fa-angle-right" aria-label="下一页"></i></a>
  </nav>



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">xudonglei</p>
  <div class="site-description" itemprop="description">搬砖 嵌入式</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">283</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">19</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">67</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2024</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">xudonglei</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : false,
      notify     : false,
      appId      : 'BT0Qw9HcTpPv1a6cT1iDBXKz-gzGzoHsz',
      appKey     : 'LMCMh8v02JTMFAwKNRcgoizI',
      placeholder: "Just go go",
      avatar     : 'mm',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : true,
      lang       : 'zh-CN' || 'zh-cn',
      path       : location.pathname,
      recordIP   : false,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
